package com.tool_stdy.RedisTest.shardPoolJedis;

import redis.clients.jedis.ShardedJedis;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/**
 * Created by Administrator on 2018/9/8/008.
 */
public class TestPool {

    public static void test01() {
        ExecutorService executorService = Executors.newFixedThreadPool(30);
        for (int i = 0; i < 3; i++) {
            final int finalI = i;
            executorService.execute(new Runnable() {
                @Override
                public void run() {
                    ShardedJedis client = JedisShardPoolClient.getClient();
                    System.out.println(client);
                    client.set("name_" + finalI, "zhangsa_" + finalI);
                    client.close();
                }
            });
        }
    }

    public static void test02() {
        for (int i = 0; i < 3; i++) {
            ShardedJedis client = JedisShardPoolClient.getClient();
            System.out.println(client);
            client.set("name_" + i, "zhangsa_" + i);
            client.close();
        }
    }

    public static void main(String[] args) {
        test01();
    }
}
